<?php
require('../config.ini.php');
require('../fpdf/fpdf.php');
$pdf=new FPDF();
$pdf->SetMargins(10,15,10);
$pdf->AddPage();
$pdf->AddFont('angsa','','angsa.php');
$pdf->SetFont('angsa','',16);
$conv = iconv("UTF-8","TIS-620","รายงานบัญชีผู้ใช้ระบบ ประเภทสมาชิก");
$pdf->Cell(0,0,$conv,0,0,'C');
$pdf->Ln(5);
$pdf->SetFont('angsa','',12);
//Loop แสดงรายการ
$sql = "SELECT * FROM `userdata` WHERE `usertype` = '1' AND `userstatus` = '1'";
$query = mysql_query($sql);
$pdf->Cell(25,8,iconv("UTF-8","TIS-620","ชื่อ"),1,0,'C');
   $pdf->Cell(25,8,iconv("UTF-8","TIS-620","นามสกุล"),1,0,'C');
   $pdf->Cell(25,8,iconv("UTF-8","TIS-620", "บัญชีผู้ใช้"),1,0,'C');
   $pdf->Cell(55,8,iconv("UTF-8","TIS-620", "ที่อยู่"),1,0,'C');
   $pdf->Cell(20,8,iconv("UTF-8","TIS-620", "โทรศัพท์"),1,0,'C');
   $pdf->Cell(40,8,iconv("UTF-8","TIS-620", "อีเมล"),1,0,'C');
   $pdf->Ln();
$cnt = 0;
while ($result = mysql_fetch_array($query))
{
   ++$cnt;
   $pdf->Cell(25,8,iconv("UTF-8","TIS-620", $result["username"]),1,0,'L');
   $pdf->Cell(25,8,iconv("UTF-8","TIS-620", $result["usersname"]),1,0,'L');
   $pdf->Cell(25,8,iconv("UTF-8","TIS-620", $result["userid"]),1,0,'L');
   $pdf->Cell(55,8,iconv("UTF-8","TIS-620", $result["tel"]),1,0,'L');
   $pdf->Cell(20,8,iconv("UTF-8","TIS-620", $result["mobile"]),1,0,'L');
   $pdf->Cell(40,8,iconv("UTF-8","TIS-620", $result["email"]),1,0,'L');
   $pdf->Ln(); //ระหว่างบรรทัด
   //ถ้า 30 รายการให้ขึ้นหน้าใหม่
   if($cnt == 35)
   {
     $cnt = 0;
     $pdf->AddPage(); //เพิ่ม หน้า
   }
}

$pdf->AddPage();
$pdf->AddFont('angsa','','angsa.php');
$pdf->SetFont('angsa','',16);
$conv = iconv("UTF-8","TIS-620","รายงานบัญชีผู้ใช้ระบบ ประเภทพนักงาน");
$pdf->Cell(0,0,$conv,0,0,'C');
$pdf->Ln(5);
$pdf->SetFont('angsa','',12);
//Loop แสดงรายการ
$sql = "SELECT * FROM `userdata` WHERE `usertype` = '2' AND `userstatus` = '1'";
$query = mysql_query($sql);
   $pdf->Cell(25,8,iconv("UTF-8","TIS-620","ชื่อ"),1,0,'C');
   $pdf->Cell(25,8,iconv("UTF-8","TIS-620","นามสกุล"),1,0,'C');
   $pdf->Cell(25,8,iconv("UTF-8","TIS-620", "บัญชีผู้ใช้"),1,0,'C');
   $pdf->Cell(55,8,iconv("UTF-8","TIS-620", "ที่อยู่"),1,0,'C');
   $pdf->Cell(20,8,iconv("UTF-8","TIS-620", "โทรศัพท์"),1,0,'C');
   $pdf->Cell(40,8,iconv("UTF-8","TIS-620", "อีเมล"),1,0,'C');
   $pdf->Ln();
$cnt = 0;
while ($result = mysql_fetch_array($query))
{
   ++$cnt;
   $pdf->Cell(25,8,iconv("UTF-8","TIS-620", $result["username"]),1,0,'L');
   $pdf->Cell(25,8,iconv("UTF-8","TIS-620", $result["usersname"]),1,0,'L');
   $pdf->Cell(25,8,iconv("UTF-8","TIS-620", $result["userid"]),1,0,'L');
   $pdf->Cell(55,8,iconv("UTF-8","TIS-620", $result["tel"]),1,0,'L');
   $pdf->Cell(20,8,iconv("UTF-8","TIS-620", $result["mobile"]),1,0,'L');
   $pdf->Cell(40,8,iconv("UTF-8","TIS-620", $result["email"]),1,0,'L');
   $pdf->Ln(); //ระหว่างบรรทัด
   //ถ้า 30 รายการให้ขึ้นหน้าใหม่
   if($cnt == 35)
   {
     $cnt = 0;
     $pdf->AddPage(); //เพิ่ม หน้า
   }
}
$pdf->AddPage();
$pdf->AddFont('angsa','','angsa.php');
$pdf->SetFont('angsa','',16);
$conv = iconv("UTF-8","TIS-620","รายงานบัญชีผู้ใช้ระบบ ประเภทผู้ดูแลระบบ");
$pdf->Cell(0,0,$conv,0,0,'C');
$pdf->Ln(5);
$pdf->SetFont('angsa','',12);
//Loop แสดงรายการ
$sql = "SELECT * FROM `userdata` WHERE `usertype` = '3' AND `userstatus` = '1'";
$query = mysql_query($sql);
   $pdf->Cell(25,8,iconv("UTF-8","TIS-620","ชื่อ"),1,0,'C');
   $pdf->Cell(25,8,iconv("UTF-8","TIS-620","นามสกุล"),1,0,'C');
   $pdf->Cell(25,8,iconv("UTF-8","TIS-620", "บัญชีผู้ใช้"),1,0,'C');
   $pdf->Cell(55,8,iconv("UTF-8","TIS-620", "ที่อยู่"),1,0,'C');
   $pdf->Cell(20,8,iconv("UTF-8","TIS-620", "โทรศัพท์"),1,0,'C');
   $pdf->Cell(40,8,iconv("UTF-8","TIS-620", "อีเมล"),1,0,'C');
   $pdf->Ln();
$cnt = 0;
while ($result = mysql_fetch_array($query))
{
   ++$cnt;
   $pdf->Cell(25,8,iconv("UTF-8","TIS-620", $result["username"]),1,0,'L');
   $pdf->Cell(25,8,iconv("UTF-8","TIS-620", $result["usersname"]),1,0,'L');
   $pdf->Cell(25,8,iconv("UTF-8","TIS-620", $result["userid"]),1,0,'L');
   $pdf->Cell(55,8,iconv("UTF-8","TIS-620", $result["tel"]),1,0,'L');
   $pdf->Cell(20,8,iconv("UTF-8","TIS-620", $result["mobile"]),1,0,'L');
   $pdf->Cell(40,8,iconv("UTF-8","TIS-620", $result["email"]),1,0,'L');
   $pdf->Ln(); //ระหว่างบรรทัด
   //ถ้า 30 รายการให้ขึ้นหน้าใหม่
   if($cnt == 35)
   {
     $cnt = 0;
     $pdf->AddPage(); //เพิ่ม หน้า
   }
}
$pdf->AddPage();
$pdf->AddFont('angsa','','angsa.php');
$pdf->SetFont('angsa','',16);
$conv = iconv("UTF-8","TIS-620","รายงานบัญชีผู้ใช้ระบบ ประเภทผู้บริหาร");
$pdf->Cell(0,0,$conv,0,0,'C');
$pdf->Ln(5);
$pdf->SetFont('angsa','',12);
//Loop แสดงรายการ
$sql = "SELECT * FROM `userdata` WHERE `usertype` = '4' AND `userstatus` = '1'";
$query = mysql_query($sql);
   $pdf->Cell(25,8,iconv("UTF-8","TIS-620","ชื่อ"),1,0,'C');
   $pdf->Cell(25,8,iconv("UTF-8","TIS-620","นามสกุล"),1,0,'C');
   $pdf->Cell(25,8,iconv("UTF-8","TIS-620", "บัญชีผู้ใช้"),1,0,'C');
   $pdf->Cell(55,8,iconv("UTF-8","TIS-620", "ที่อยู่"),1,0,'C');
   $pdf->Cell(20,8,iconv("UTF-8","TIS-620", "โทรศัพท์"),1,0,'C');
   $pdf->Cell(40,8,iconv("UTF-8","TIS-620", "อีเมล"),1,0,'C');
   $pdf->Ln();
$cnt = 0;
while ($result = mysql_fetch_array($query))
{
   ++$cnt;
   $pdf->Cell(25,8,iconv("UTF-8","TIS-620", $result["username"]),1,0,'L');
   $pdf->Cell(25,8,iconv("UTF-8","TIS-620", $result["usersname"]),1,0,'L');
   $pdf->Cell(25,8,iconv("UTF-8","TIS-620", $result["userid"]),1,0,'L');
   $pdf->Cell(55,8,iconv("UTF-8","TIS-620", $result["tel"]),1,0,'L');
   $pdf->Cell(20,8,iconv("UTF-8","TIS-620", $result["mobile"]),1,0,'L');
   $pdf->Cell(40,8,iconv("UTF-8","TIS-620", $result["email"]),1,0,'L');
   $pdf->Ln(); //ระหว่างบรรทัด
   //ถ้า 30 รายการให้ขึ้นหน้าใหม่
   if($cnt == 35)
   {
     $cnt = 0;
     $pdf->AddPage(); //เพิ่ม หน้า
   }
}

$pdf->Output();
?>
